<?php
namespace Store\Controller;
use Think\Controller;

class IndexController extends Controller {
	/**
	 * 登录
	 */
	public function login(){
		if(IS_POST){
			$code = $_POST['code'];
			$util = A('Util');
			if($util->check_verify($code)) {
				$where['name'] = $_POST['name'];
				$scenic = D('Scenic');
				$arr = $scenic->where($where)->find();
				if(md5($_POST['password']) == $arr['password']){
					session('store',$arr);
					$this->success("登录成功！",U("ScenicOrder/index"));
				}else{
					$this->error("账号或者密码错误！");
				}
			}else{
				$this->error("验证码错误！");
			}
		}else{
			$this->display();
		}
	}
	/**
	 * 注销
	 */
	public function logout() {
		session('[destroy]');
		$this->success('退出登录成功',U('Index/login'));
	}
}